import React, { PureComponent, Fragment } from 'react';
import { connect } from 'dva';
import router from 'umi/router';
import {Icon} from 'antd';
import PageHeaderLayout from '../../layouts/PageHeaderLayout';
import styles from '../Pbulic.less';



@connect()
export default class PlanDetail extends PureComponent {
  constructor(props) {
    super(props);
  }


  componentDidMount() {

  }


  componentWillUnmount(){
    const { dispatch } = this.props;
    dispatch({
      type: `plan/appendClearState`,
    })
  }


  goBack = () => {
    // this.props.onClose(0);
    const { dispatch, location } = this.props;
    router.push({ pathname:'/maintain/plan/list',  query: { ...location.query} });
  }

  render() {
    const { history, match,routerData, children} = this.props;
    const location_arry = history.location.pathname.split("/");
    const tabDefaultKeys = location_arry[location_arry.length - 1];
    const tabDefaultKeys2 = location_arry[location_arry.length - 2];

    return (
      <Fragment>
        <Icon type="close-circle-o"  className={styles.close_icon} onClick={this.goBack}/>
        <PageHeaderLayout
          hiddenBreadcurmb={true}
          title={tabDefaultKeys=='add' ? '新增计划' : tabDefaultKeys2=='edit' ? '编辑计划' : '计划详情'}
        >
          {children}

        </PageHeaderLayout>
      </Fragment>
    );
  }
}
